var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, i) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var i in t)
              Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
          })(t, i);
      };
      return function (t, i) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof i && null !== i)
          throw new TypeError(
            "Class extends value " + String(i) + " is not a constructor or null"
          );
        e(t, i),
          (t.prototype =
            null === i
              ? Object.create(i)
              : ((a.prototype = i.prototype), new a()));
      };
    })(),
  Box = Laya.Box,
  Button = Laya.Button,
  MapCityAreaView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.cellHeight = 35),
        (t.isShow = !0),
        (t.lastVisible = !1),
        t.btn_city_back.on(Laya.Event.CLICK, t, t.onCityBackPreFn),
        (t.cityList.selectHandler = new Handler(t, t.onSelectCity)),
        (t.cityList.renderHandler = new Handler(t, t.renderSite)),
        (t.siteList.selectHandler = new Handler(t, t.onSelectSite)),
        (t.siteList.renderHandler = new Handler(t, t.renderSite)),
        t.cityList.on(Laya.Event.CLICK, t, t.siteClick),
        t.siteList.on(Laya.Event.CLICK, t, t.siteClick),
        (t.cityList.vScrollBarSkin = ""),
        (t.siteList.vScrollBarSkin = ""),
        WebSocketService.addListener(
          { caller: t, code: 1418, method: t.receiveData },
          !0
        ),
        WebSocketService.addListener(
          { caller: t, code: 1436, method: t.receiveData },
          !0
        ),
        WebSocketService.addListener(
          { caller: t, code: 1437, method: t.gotoSite },
          !0
        ),
        WebSocketService.addListener(
          { caller: t, code: 1826, method: t.receiveData },
          !0
        ),
        WebSocketService.addListener({
          caller: t,
          code: 1806,
          method: t.onLoadQuitFuBenData,
        }),
        t.btn_fuben_likaimidao.on(Laya.Event.CLICK, t, t.onFuBenNPCMiDaoAction),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openMapView = function (e) {
        var i = this.mapcityV;
        null == i && ((i = new t()), (this.mapcityV = i)),
          i.isShow && (Laya.stage.addChild(i), (i.isShow = !1)),
          (i.visible = !0),
          (i.lastVisible = !0),
          i.init(e);
      }),
      (t.resetShow = function () {
        var e = this.mapcityV;
        null != e && (e.removeSelf(), (e.isShow = !0));
      }),
      (t.prototype.isFubenView = function () {
        Global.isFuBen
          ? (this.btn_fuben_likaimidao.visible = !0)
          : (this.btn_fuben_likaimidao.visible = !1);
      }),
      (t.prototype.init = function (e) {
        this.isFubenView(),
          (this.areaId = "a-" + e),
          t.cache[this.areaId]
            ? this.receiveData(t.cache[this.areaId])
            : Global.isFuBen
            ? WebSocketService.send({ c: 1826, d: { fbId: e } })
            : WebSocketService.send({ c: 1418, d: { areaId: e } }),
          (this.cityList.selectedIndex = -1),
          (this.siteList.selectedIndex = -1),
          (this.cityList.visible = !1),
          (this.siteList.visible = !1),
          (this.image_first_leve.visible = !1),
          (this.image_second_leve.visible = !1);
      }),
      (t.changeMapView = function () {
        null != this.mapcityV &&
          (this.mapcityV.visible = this.mapcityV.lastVisible);
      }),
      (t.hiden = function () {
        this.mapcityV && this.mapcityV.visible && (this.mapcityV.visible = !1);
      }),
      (t.prototype.onCityBackPreFn = function () {
        (this.visible = !1), (this.lastVisible = !1);
      }),
      (t.prototype.receiveData = function (e) {
        if (0 == e.code) {
          for (var i, a, n = e.list, s = [], o = 0; o < n.length; o++)
            (i = n[o].name),
              (a = { id: n[o].id, siteName: { text: i } }),
              s.push(a);
          if (
            (1418 == e.act_id &&
              ((this.cityList.visible = !0),
              (this.image_first_leve.visible = !0),
              (this.cityList.array = s),
              (this.image_first_leve.height = this.cellHeight * s.length + 3),
              t.cache["a-" + this.areaId] || (t.cache["a-" + this.areaId] = e)),
            1436 == e.act_id)
          ) {
            (this.siteList.visible = !0),
              s.length > 0 && (this.image_second_leve.visible = !0),
              (this.siteList.array = s),
              (this.image_second_leve.height = this.cellHeight * s.length + 3);
            var c = this.cityList.selectedItem;
            t.cache[c.id] || (t.cache[c.id] = e);
          }
          1826 == e.act_id &&
            ((this.cityList.visible = !0),
            (this.image_first_leve.visible = !0),
            (this.cityList.array = s),
            (this.image_first_leve.height = this.cellHeight * s.length + 3),
            t.cache["a-" + this.areaId] || (t.cache["a-" + this.areaId] = e));
        }
      }),
      (t.prototype.renderSite = function (e, t) {
        var i = e.getChildByName("siteName"),
          a = e.getChildByName("btn_goto");
        if (t == e.parent.parent.selectedIndex)
          (i.bgColor = "#9c03a3"), (a.visible = !0);
        else {
          (e.getChildByName("btn_goto").visible = !1), (i.bgColor = "#5b005f");
        }
      }),
      (t.prototype.onSelectCity = function (e) {
        if (!(e < 0)) {
          var i = this.cityList.selectedItem;
          t.cache[i.id]
            ? this.receiveData(t.cache[i.id])
            : WebSocketService.send({ c: 1436, d: { pid: i.id } }),
            (this.siteList.selectedIndex = -1);
        }
      }),
      (t.prototype.onSelectSite = function (e) {
        if (!(e < 0)) this.siteList.array[e];
      }),
      (t.prototype.gotoSite = function (e) {
        0 == e.code
          ? (ToastView.toastView("已到达目的地"),
            (this.visible = !1),
            Laya.stage.event("GameMainView", "person"),
            Laya.stage.event("HomePageView", "person"))
          : ToastView.toastView(e.msg);
      }),
      (t.prototype.siteClick = function (e) {
        if ("btn_goto" == e.target.name) {
          var t = e.currentTarget.selectedItem;
          WebSocketService.send({ c: 1437, d: { siteId: t.id } });
        }
      }),
      (t.prototype.onLoadQuitFuBenData = function (e) {
        Laya.stage.event("HomePageView", "loadingFuben"),
          Laya.stage.event("GameMainView", "loadingFuben"),
          Laya.stage.event("GameMainView", "loadingFuben_MainTab"),
          this.onCityBackPreFn();
      }),
      (t.prototype.onFuBenNPCMiDaoAction = function () {
        NormalDialog.showNormalDialog(
          "您确定要退出副本吗？",
          this,
          this.onLoadQuitFuBenMethod
        );
      }),
      (t.prototype.onLoadQuitFuBenMethod = function () {
        WebSocketService.send({ c: 1806 });
      }),
      (t.cache = {}),
      t
    );
  })(ui.MapCityAreaViewUI);
